
package com.answeringplayer.controller;

import com.answeringplayer.Bean.Response;
import com.answeringplayer.dto.CaptchaDTO;
import com.answeringplayer.exception.BusinessException;
import com.answeringplayer.service.CaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/captcha")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    @GetMapping("/generate")
    public Response<CaptchaDTO> generateCaptcha() {
        try {
            CaptchaDTO resp = captchaService.generateCaptcha();
            return Response.success("验证码生成成功", resp);
        } catch (Exception e) {
            throw new BusinessException(500, "验证码生成失败");
        }
    }
}